package xurui.test.dbtest.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class DbTestController {
    @Autowired
    JdbcTemplate jdbcTemplate;

    @RequestMapping(value = "/healthcheck", method = RequestMethod.GET)
    public String healthcheck() {
        return "OK";
    }

    @RequestMapping(value = "/foo", method = RequestMethod.GET)
    public String testDb() {

        int count = jdbcTemplate.queryForObject("SELECT COUNT(1) FROM DEAL_ORDER_FCODE", new Object[]{}, Integer.class);

        return String.format("DEAL_ORDER_FCODE Row count=%d", count);
    }

}